<?php
namespace app\index\controller;


use app\index\controller\FrontBase;
use think\Config;
use think\Request;
use app\common\model\Tips as TipsModel;
use app\common\model\Fileware as FilewareModel;
use app\common\model\DownloadCate as DownloadCateModel;

class Download extends FrontBase
{
    /**
     * 下载列表页
     */
    public function index(){


        return view('',$this->param);
    }


    /**
     *
     * @param Request $request
     */
    public function category(Request $request){
        $id = $request->request('id');

        return view('',$this->param);
    }


    /**
     * 文件下载
     * @param Request $request
     */
    public function download(Request $request){
        $id = $request->param('id');
        $file = FilewareModel::where(['id'=>$id])->find();

        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="'.$file['originname'].'"');
        header('Content-Transfer-Encoding: binary');
        $path = ROOT_PATH.'public'.str_replace("\\",'/',$file['url']);

        echo file_get_contents($path);
    }
}